import QtQuick 2.0
import VPlay 2.0

// is shown at game start and shows the maximum highscore and a button for starting the game
SceneBase {
  id: mainScene

  Connections {
    // nativeUtils should only be connected, when this is the active scene
      target: activeScene === mainScene ? nativeUtils : null
      onMessageBoxFinished: {
        console.debug("the user confirmed the Ok/Cancel dialog with:", accepted)
        if(accepted)
          Qt.quit()
      }
  }

  onBackPressed: {
    nativeUtils.displayMessageBox(qsTr("Really quit the game?"), "", 2);
    // instead of immediately shutting down the app, ask the user if he really wants to exit the app with a native dialog
    //Qt.quit()
  }

  MultiResolutionImage {
    source: "../assets/img/background_menu.png"
    anchors.centerIn: parent
  }

  Column{
    anchors.bottom: parent.bottom
    anchors.horizontalCenter: parent.horizontalCenter
    spacing: 15

      MenuText {
        text: "Highscore: " + maximumHighscore
      }

      Row {

        spacing: 10
    //    anchors.verticalCenter: parent.verticalCenter
        anchors.horizontalCenter: parent.horizontalCenter
//        anchors.horizontalCenterOffset: -35

        MenuButton {
//          width: 100
//          height: 100

          text: "Play"

          onClicked: {
              window.state = "game"
            //  window.chartboost.loadInterstitial();
              textSize: 25
            }
        }


//        MenuButton {
//          text: "Highscores"

////          width: 100
////          height: 100

//          // this button opens the gamecenter leaderboards - only show it if the gamecenter is available (so iOS only)
//          visible: gameCenter.authenticated

//          onClicked: gameCenter.showLeaderboard();
//        }

        MenuButton {
            text: "Preferences"

//          width: 100
//          height: 100

          onClicked: window.state = "preferences"
//          onClicked: settings.soundEnabled = !settings.soundEnabled


          // this button should only be displayed on Symbian & Meego, because on the other platforms the volume hardware keys work; but on Sym & Meego the volume cant be adjusted as the hardware volume keys are not working
          // also, display it when in debug build for quick toggling the sound
          visible: system.debugBuild || system.isPlatform(System.Android) || system.isPlatform(System.IOS)
        }

        MenuButton {
          text: "Credits"

//          width: 100
//          height: 100

          onClicked: window.state = "credits";
        }
      }

  }



  // this allows navigation through key presses
  Keys.onReturnPressed: {
    window.state = "game"
  }
}
